<template>
    <div>
        <el-row :gutter="24">
            <el-col :md="3" :sm="6">{{ $t('channel name') }}</el-col>
            <el-col :md="3" :sm="6">{{ $t('Mode') }}</el-col>
            <el-col :md="3" :sm="6">IP</el-col>
            <el-col :md="3" :sm="6">StreamID</el-col>
            <el-col :md="3" :sm="6">{{ $t('Port') }}</el-col>
            <el-col :md="3" :sm="6">{{ $t('Latency') }}</el-col>
            <el-col :md="3" :sm="6">{{ $t('Password') }}</el-col>
            <el-col :md="2" :sm="4">{{ $t('enable') }}</el-col>
        </el-row>
        <div v-for="dataItem in dataList">
            <el-divider></el-divider>
            <el-row :gutter="24" style="margin-top:16px" v-for="(data, index) in dataItem.streamList">
                <el-col :md="3" :sm="6">
                    <el-input v-if="index == 0" v-model="dataItem.name" :placeholder="$t('input_placeholder')"></el-input>
                </el-col>
                <el-col :md="3" :sm="6">
                    <el-select v-model="data.srt.mode" :placeholder="$t('select_placeholder')" style="width: 100%;">
                        <el-option label="caller" value="caller"></el-option>
                        <el-option label="listener" value="listener"></el-option>
                        <el-option label="rendezvous" value="rendezvous"></el-option>
                    </el-select>
                </el-col>
                <el-col :md="3" :sm="6">
                    <el-input v-model="data.srt.ip" :placeholder="$t('input_placeholder')"></el-input>
                </el-col>
                <el-col :md="3" :sm="6">
                    <el-input v-model="data.srt.streamid" :placeholder="$t('input_placeholder')"></el-input>
                </el-col>
                <el-col :md="3" :sm="6">
                    <el-input v-model="data.srt.port" :placeholder="$t('input_placeholder')"></el-input>
                </el-col>
                <el-col :md="3" :sm="6">
                    <el-input v-model="data.srt.latency" :placeholder="$t('input_placeholder')"></el-input>
                </el-col>
                <el-col :md="3" :sm="6">
                    <el-input v-model="data.srt.passwd" :placeholder="$t('input_placeholder')"></el-input>
                </el-col>
                <el-col :md="2" :sm="4">
                    <el-switch v-model="data.srt.enable" inline-prompt active-text="ON" inactive-text="OFF"></el-switch>
                </el-col>
            </el-row>
        </div>
    </div>
</template>
  
<script setup name="video-stream">
const props = defineProps(['data'])
let dataList = ref([])

watchEffect(() => {
    dataList.value = props.data?.length ? props.data.map(item => {
        let udp1 = item.stream.udp
        item.stream.udp.ip_port = `${udp1.ip}:${udp1.port}`
        let udp2 = item.stream2.udp
        item.stream2.udp.ip_port = `${udp2.ip}:${udp2.port}`

        item.streamList = [item.stream, item.stream2]
        return item
    }) : []
})

onUnmounted(() => {

});

</script>
  
<style scoped lang="scss">
.encode-setting {}
</style>
  
  